//
//  KLComposeDetailController.m
//  KL
//
//  Created by mac on 15/12/21.
//  Copyright © 2015年 zhouxubin. All rights reserved.
//

#import "KLComposeDetailController.h"
#import "KLCompose.h"
#import "KLComposeCell.h"
#import "KLWebViewController.h"
#import "NavViewController.h"

@interface KLComposeDetailController ()

@end

@implementation KLComposeDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 标题
    self.title = @"比价详情";
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    // 行高
    self.tableView.rowHeight = 150;
    // 底部视图
    self.tableView.tableFooterView = [[UIView alloc] init];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.composeList.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    // 创建cell
    KLComposeCell *cell = [KLComposeCell composeCellWith:tableView];
    
    // 取出模型
    KLCompose *compose = self.composeList[indexPath.row];
    cell.compose = compose;
    
    return cell;
}

#pragma mark 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    KLComposeCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    cell.selected = NO;
    // 取出点击cell的模型
    KLCompose *compose = self.composeList[indexPath.row];
    
    // 点击cell的时候加载网页
    KLWebViewController *webVc = [[KLWebViewController alloc] init];
    webVc.htmlSite = compose.spurl;
    NavViewController *nav = [[NavViewController alloc] initWithRootViewController:webVc];
    [self presentViewController:nav animated:YES completion:nil];
}

@end
